﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HollywoodHackers.Storage.Queue;

namespace HollywoodHackers.Web.Controllers
{
    public class ShoppingCartController : Controller
    {
        ShoppingCartRepository cartRepository;

        public ShoppingCartController()
        {
            cartRepository = new ShoppingCartRepository(QueueNames.ShoppingCart);
        }

        public ActionResult Submit()
        {
            ShoppingCart cart = new ShoppingCart();
            cart.UserName = User.Identity.Name;
            cart.Discounts = 12.50f;
            cart.CartID = Guid.NewGuid().ToString();

            List<ShoppingCartItem> items = new List<ShoppingCartItem>();
            items.Add(new ShoppingCartItem() { Quantity = 12, SKU = "10000101010", UnitPrice = 15.75f });
            items.Add(new ShoppingCartItem() { Quantity = 27, SKU = "12390123j213", UnitPrice = 99.92f });

            cart.CartItems = items.ToArray();
            cartRepository.EnqueueShoppingCart(cart);
            return View();
        }
    }
}
